#include <iostream>
#include <string>
#include <regex>

int main(){
    // std::string str = "/number/1234";
    // std::regex pattern("/number/(\\d+)");
    // std::smatch matches;
    // int ret = std::regex_match(str,matches,pattern);
    // if(!ret){
    //     return -1;
    // }
    // for(auto& e : matches){
    //     std::cout << e << std::endl;
    // }

    std::string str="GET /admin/login?user=root&password=123456 HTTP/1.1\r\n";
    std::regex pattern("(GET|POST|PUT|DELETE|HEAD) ([^?]*)(?:\\?(.*))? (HTTP/1\\.[01])(?:\n|\r\n)?");
    std::smatch matches;
    int ret = std::regex_match(str,matches,pattern);
    if(!ret){
        return -1;
    }
    for(auto& elem:matches){
        std::cout << elem << std::endl;
    }
    return 0;
}